/*
 * 存储管理 store.js
 * @Author: Ray
 * @Date:   2018-01-31
 */
;(function(window){
	'use strict';

	var hooks = {};

	hooks.StoreKeys = {
		ACCESS_TOKEN: 'AccessToken',
		SAAS_USER_DATA: 'saasUserData',
		USER_DATA: 'userData',
		GUIDE: 'guide',
		BLE_SCOPE: 'bleScope',
		IS_ADDING_AMW: 'isAddingAMW',
	};

	/**
     * 设置数据
     * @param {Object} value 用户数据
     */
	hooks.setData = function(key, value) {
		$api.setStorage(key, value);
	};

	/**
     * 设置token
     * @param {String} token
     */
	hooks.setAccessToken = function(token) {
		$api.setStorage(this.StoreKeys.ACCESS_TOKEN, token);
		// window.localStorage.setItem(this.StoreKeys.ACCESS_TOKEN, token)
	};

	/**
     * 设置用户数据
     * @param {Object} value 用户数据
     */
	hooks.setUserData = function(value) {
		$api.setStorage(this.StoreKeys.USER_DATA, value);
	};

	//获取token
	hooks.getAccessToken = function() {
		return $api.getStorage(this.StoreKeys.ACCESS_TOKEN);
	};

	//获取SAAS用户数据
	hooks.getSaasUserData = function() {
		return $api.getStorage(this.StoreKeys.SAAS_USER_DATA);
	};

	//获取用户数据
	hooks.getUserData = function() {
		return $api.getStorage(this.StoreKeys.USER_DATA);
	};

	//是否在绑定AMW
	hooks.isAddingAMW = function() {
		return $api.getStorage(this.StoreKeys.IS_ADDING_AMW);
	};

	window.$store = hooks;

})(window);